<?php
namespace app\home\controller\agent;
use app\home\controller\Base;

use app\common\query\Member;

class Api extends Base
{
	/**
	 * 报单中心会员列表接口
	 * @return [type] [description]
	 */
	public function member_rows(){
		$params = $this->request->param();
        
        $perpagenum = isset($params['limit'])?intval($params['limit']):15;
        $perpagenum = $perpagenum>100?100:$perpagenum;
        $page = isset($params['page'])?intval($params['page']):1;
        $page = $page<1?1:$page;

        unset($params['limit']);
        unset($params['page']);
        $where = [];
        if(isset($params['key'])){
            $where= parseWhere($params['key'],true);
        }
        $where['agent_id'] = UID;

        $data = model('member')->getPageDatas($where,$page,$perpagenum);
        $data['code'] = 1;
        return json($data);
	}


	public function member_map(){
		$params = $this->request->param();
		$mid = isset($params['mid'])?$params['mid']:'';
		if(!$mid)
			$mid = MID;

		$query = new Member;
		if($mid!=MID){
			if($query->getOneValue(['mid'=>$mid],'agent_id')!=MID){
				return json(['code'=>0,'msg'=>'该用户不在当前代理网络下']);
			}
		}
		$data = $query->queryMap($mid);
		return json(['code'=>1,'msg'=>'查询成功','data'=>$data]);

	}

}